<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
                      "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
    <title>FileWriter Example</title>

    <script type="text/javascript" charset="utf-8" src="phonegap.0.9.4.js"></script>
    <script type="text/javascript" charset="utf-8">

    // Wait for PhoneGap to load
    //
    function onLoad() {
        document.addEventListener("deviceready", onDeviceReady, false);
    }

    // PhoneGap is ready
    //
    function onDeviceReady() {
        window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
    }

    function gotFS(fileSystem) {
        fileSystem.root.getFile("readme.txt", null, gotFileEntry, fail);
    }

    function gotFileEntry(fileEntry) {
        fileEntry.createWriter(gotFileWriter, fail);
    }

    function gotFileWriter(writer) {
        writer.onwrite = function(evt) {
            console.log("write success");
        };
        writer.write("some sample text");
        // contents of file now 'some sample text'
        writer.truncate(11);
        // contents of file now 'some sample'
        writer.seek(4);
        // contents of file still 'some sample' but file pointer is after the 'e' in 'some'
        writer.write(" different text");
        // contents of file now 'some different text'
    }

    function fail(error) {
        console.log(error.code);
    }

    </script>
  </head>
  <body onload="onLoad()">
    <h1>Example</h1>
    <p>Write File</p>
  </body>
</html>